$(document)
		.ready(
				function() {
					var rowNum = 0;
					var contextPath = document.location.pathname;
					var index = contextPath.substr(1).indexOf("/");
					contextPath = contextPath.substr(1, index);
					var basePath = "/" + contextPath;
					var totalCount = $("#totalCount").val();
					var pSize = $("#pageSize").val();
					var pageIndex = $("#pageIndex").val();
					var pageCount = $("#pageCount").val();
					var isReading = false; // 是否处于监视用户输入状态
					var giftArr = new Array();// 定义一个数组，用来存储礼品实体
					var addPageCount = 1;// 初始化为1
					var len = 0;// 标记数组的长度，删除时-1
					var sumArr = new Array();//记录订单详情的总额
					var bkGoodsArr = new Array();//该数组用来存储退货的礼品规格
					var message = $("#message").val();//message 判断退货是否成功
					
					getPostType();
					var validObject = $("#orderInfo").Validform({
						tiptype:2,
						tiptype:function(msg,o,cssctl){
							
							if(!o.obj.is("form")){
								var tds=o.obj.text();
								
								var objtip=o.obj.siblings(".Validform_checktip");
								cssctl(objtip,o.type);
								objtip.text(msg);
							
								
							}	
							
						}
					
					});
					
					if(message=="success"){
						alert("退货成功");
					}
					if(message=="fail"){
						alert("退货失败");
					}
					
					/*
					 * 
					 * 删除添加的记录
					 */
					$("#itemsTable")
							.delegate(
									"button[name='delItem']",
									'click',
									function() {
										if (confirm("是否要删除该记录?") == true) {
											var trId = $(this).attr("rowId");
											var id = $(this).parent().parent().attr("id");
											var itemId = $("#id_" + id).val();
											if (itemId == null || itemId == ""|| itemId == "undefined") {
												giftArr.splice(trId,1);
												$(this).parent().parent().remove();
												//重新计算订单总额
												computerOrderSummery();
												len = giftArr.length;
												getQuery(len);
											} else {
												var delUrl = "delItemById.do";
												$
														.ajax({
															url : delUrl,
															dataType : 'text',
															data : {
																id : id
															},
															cache : false,

															success : function(data) {
																alert("delete Data successfully");
																giftArr.splice(trId,1);
																$(this).parent().parent().remove();
																len = giftArr.length;
																getQuery(len);
																return;
															},
															error : function(html) {
																alert("delete Data failly");
																return;
															}
														});
											}
										}

									});
					/*
					 * 
					 * 删除退货单的记录
					 */
					$("#goodsTable")
					.delegate(
							"button[name='delGoodsItem']",
							'click',
							function() {
								if (confirm("是否要删除该记录?") == true) {
									var trId = $(this).attr("rowId");
									var itemId = $("#id_" + trId).val();
									var id = $(this).parent().parent().attr("id");
									bkGoodsArr.splice(trId,1);
										$(this).parent().parent().remove();
										len = bkGoodsArr.length;
										getQueryForBG(len);
								}
								
							});
					/**
					 * 模态框关闭时调用
					 */
					$("#orderDetails").on('hide.bs.modal', function() {
						$("#baseTab").addClass("active");
						$("#baseInfor").addClass("active");
						$("#detailTab").removeClass("active");
						$("#detail").removeClass("active");
						$("#returnTab").removeClass("active");
						$("#returnTab").removeClass("#returnDetail");
					});
					
					/**
					 * 保存与修改
					 */
					$("#optBtn").delegate('#saveBtn', 'click', function() {

						$("#orderInfo").attr("method", "post");
						
						var orderId = $("#orderId").val();
						var summery = $("#summery").val();
						var mailFeed = $("#mailFeed").val();
						
						var summeryTotal = parseFloat(summery)+parseFloat(mailFeed);
						$("#summery").val(summeryTotal);
						if (orderId == "") {
							$("#orderInfo").attr("action", "save.do");
						} else {

							$("#orderInfo").attr("action", "update.do");
						}
						$("#orderInfo").submit();
						

					});
					/**
					 * 退货 保存
					 */
					$("#optBtn").delegate('#returnGoodsBtn', 'click', function() {
						
						$("#orderInfo").attr("method", "post");
							$("#orderInfo").attr("action", "backGoods.do");
							clearItemTable();
							clearGoodsTable();
							var goodsTable = $("#goodsTable");
							goodsTable.css("display","none");
								for(i=0;i<giftArr.length;i++){
									addGoodsItemContent(goodsTable,bkGoodsArr[i],i);
								}
							$("#orderInfo").submit();
						
					});
					/**
					 * 确认发货
					 */
					$("#optBtn").delegate('#confirmBtn', 'click', function() {
						if(confirm("您确定要发货吗?")){
							var orderId = $("#orderId").val();
							var detailsUrl=basePath+ "/manage/order/show.do?id="+orderId;
							$.ajax({
								url : detailsUrl,
								dataType : "json",
								success : function(data) {
									alert("successfully");
									//0 电子付款
									if(data.payType == 0){
										//如果已经付款
										if(data.status==1){
											/**
											 * 1.通过orderId获取订单详情
											 * 2.通过订单详情获取礼品规格的数量
											 * 3.通过礼品规格id获取规格的库存量
											 * 4.判断：如果库存量小于礼品规格的数量，提示修改礼品规格数量,发货失败。
											 */
											//发货
											sendGiftMethod(orderId);
										}
										else{
											if(data.status == 0){
												
												alert("用户还没付款，不能发货");
											}else{
												alert("亲，已经发货了");
											}
											
										}
									}
									//1货到付款 直接发货
									else{
										//发货
										sendGiftMethod(orderId);
									}
									
									$("#orderDetails").modal('hide');
									
								},
								error : function(data) {
									alert("加载数据出错");
									return;
								}
							});
						}
						
					});
					/**
					 * 检查库存
					 * 
					 * 1.通过礼品规格Id获取规格数量
					 */
					function checkStocks(giftDetailId){
						var queryUrl = basePath+ "/manage/giftDetail/getGiftDetailTotals.do?id="+giftDetailId;
						$.ajax({
							url : queryUrl,
							dataType : 'json',
							cache : false,
							success : function(data) {

								alert("data success!!");
								alert("礼品规格数量-------"+data);
							},
							error : function(html) {
								alert("出错了");
								return;
							}
						});

					}
					/**
					 * 获取订单的表单值
					 */
					function getOrderValue() {
						var summery = $('#summery').val();
						var postCode = $('#postCode').val();
						var receAddr = $('#receAddr').val();
						var memberName = $('#memberName').val();
						var receiver = $('#receiver').val();
						if (summery == "" || postCode == "" || receAddr == ""|| memberName == "" || receiver == "") {
							return true;
						} else {
							return false;
						}
					}

					$('#pagination2')
							.jqPaginator(
									{
										totalCounts:totalCount,
										pageSize:pSize,
										visiblePages : pageCount,
										currentPage : 1,
										prev : '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
										page : '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
										next : '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
										onPageChange : function(num, type) {
											$("#pageIndex").val(num);
											var queryUrl = "queryByPage.do";
											$
													.ajax({
														url : queryUrl,
														dataType : 'json',
														data : {
															pageIndex : num,
															pageSize : pSize
														},
														cache : false,
														success : function(data) {
															$(
																	"#orderList tr:not(:first)").remove();
															var results = data.pageResult.resultList;
															for (i = 0; i < results.length; i++) {
																var order = results[i];
																var rowContent = "<tr>"
																		+ "<td><input name='orderId' class='checkbox' type='checkbox' value='"
																		+ order.id
																		+ "'/></td>"
																		+ "<td>"
																		+ order.orderCode
																		+ "</td>"
																		+ "<td>"
																		+ order.summery
																		+ "</td>"
																		+ "<td>"
																		+ order.createOrderTime
																		+ "</td>"
																		+ "<td>"
																		+ order.receAddr
																		+ "</td>";
																rowContent = rowContent
																		+ "<td>"
																		+ order.mailFeed
																		+ "</td>"
																		+ "<td>";
																if(order.payType==0){
																	rowContent = rowContent+
																	 "电子付款"+"</td><td>";
																}
																else{
																	rowContent = rowContent
																	+ "货到付款"+"</td><td>";
																}
																if (order.status == 0) {
																	rowContent = rowContent
																			+ "已下单";
																} else if (order.status == 1) {
																	rowContent = rowContent
																			+ "已付款";
																} else if (order.status == 2) {
																	rowContent = rowContent
																			+ "已发货";
																} else if (order.status == 3) {
																	rowContent = rowContent
																			+ "已收货";
																} else if (order.status == 4) {
																	rowContent = rowContent
																			+ "已确认";
																} else if (order.status == 5) {
																	rowContent = rowContent
																			+ "申请退货";
																} else if (order.status == 6) {
																	rowContent = rowContent
																			+ "已退货";
																} else {
																	rowContent = rowContent
																			+ "已退款";
																}

																rowContent = rowContent
																		+ "</td>";
																
																if(order.status>=2){
																	rowContent = rowContent+ "<td><button name='watchGiftBtn' id='editBtn' objId='"
																	+ order.id
																	+ "' class='btn btn-sm-block'>查看</button></td>";
																}
																else{
																	rowContent = rowContent+ "<td><button name='editBtn' type='button' id='editBtn' objId='"
																	+ order.id
																	+ "' class='btn btn-sm-block'>修改</button></td>";
																}
																if(order.status==1||(order.status==0&&order.payType==1)){
																	rowContent = rowContent	+ "<td><button name='sendBtn' id='editBtn' objId='"
																	+ order.id
																	+ "' class='btn btn-info btn-large'>发货</button></td>";
																	
																	rowContent = rowContent	+ 
																	"<td><button name='returnGoodsBtn' id='editBtn' objId='"+order.id+"' class='btn btn-info btn-danger' disabled='disabled'>退货</button></td>"+
																	"<td><button name='returnMoneyBtn' id='editBtn' objId='"+order.id+"' class='btn btn-warning btn-large' disabled='disabled'>退款</button></td>"
																	+ "</tr>";
																}
																else{
																	if(order.status>=4){
																		
																		rowContent = rowContent	+ "<td><button name='sendBtn' id='editBtn' objId='"
																		+ order.id
																		+ "' class='btn btn-info btn-large' disabled='disabled'>发货</button></td>";
																		
																		rowContent = rowContent	+ 
																		"<td><button name='returnGoodsBtn' id='editBtn' objId='"+order.id+"' class='btn btn-info btn-danger' >退货</button></td>"+
																		"<td><button name='returnMoneyBtn' id='editBtn' objId='"+order.id+"' class='btn btn-warning btn-large'>退款</button></td>"
																		+ "</tr>";
																	}
																	else{
																		
																		rowContent = rowContent	+ "<td><button name='sendBtn' id='editBtn' objId='"
																		+ order.id
																		+ "' class='btn btn-info btn-large' disabled='disabled'>发货</button></td>";
																		
																		rowContent = rowContent	+ 
																		"<td><button name='returnGoodsBtn' id='editBtn' objId='"+order.id+"' class='btn btn-info btn-danger' disabled='disabled'>退货</button></td>"+
																		"<td><button name='returnMoneyBtn' id='editBtn' objId='"+order.id+"' class='btn btn-warning btn-large' disabled='disabled'>退款</button></td>"
																		+ "</tr>";
																	}
																}
																$("#orderList").append(rowContent);
															}

														},
														error : function(html) {
															return;
														}
													});
										}
									});
					/**
					 * 查询订单的功能
					 */
					$("#conditions").delegate('#queryBtn', 'click', function() {
						var statu = $("#statu").val();
						var startTime = $("#startTime").val();
						var endTime = $("#endTime").val();
						alert("query------");
						alert("statu--------" + statu);
						alert("startTime--------" + startTime);
						alert("endTime--------" + endTime);
						// 执行查询
						queryOrder(statu, startTime, endTime);

					});
					/**
					 * 查询订单
					 */
					function queryOrder(statu, startTime, endTime) {

						var queryUrl = "queryByConditions.do";
						$.ajax({
							url : queryUrl,
							type : "POST",
							dataType : 'json',
							data : {
								pageIndex : pageIndex,
								pageSize : pSize,
								statu : statu,
								startTime : startTime,
								endTime : endTime
							},
							cache : false,
							success : function(data) {

								alert("data success!!");
							},
							error : function(html) {
								alert("出错了");
								return;
							}
						});

					}

					/**
					 * 根据orderId查找订单详情
					 */
					$("#orderInfo")
							.delegate(
									'#detailInfor',
									'click',
									function() {
										
										var orderId = $('#orderId').val();
										
										if (orderId != "") {
											var queryUrl = basePath+ "/manage/order/orderDetail/queryOrderDetail.do";
											clearArrAll();//清除数组
											$.ajax({
														url : queryUrl,
														type : "POST",
														dataType : 'json',
														data : {
															id : orderId
														},
														cache : false,
														success : function(data) {
															
															len = data.resultList.length;
															for (i = 0; i < len; i++) {
																var result = data.resultList[i];
																giftArr.push(result);
															}
															getQuery(len);
														},
														error : function(html) {
															alert("出错了");
															return;
														}
													});
										} else {
											/**
											 * 添加的内分页
											 */
											$('#itemPagination')
													.jqPaginator(
															{
																totalPages : addPageCount,
																visiblePages : 10,
																currentPage : 1,
																prev : '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
																page : '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
																next : '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
																onPageChange : function(num,type) {
																	clearItemTable();
																	getQuery(len);

																}
															});
										}

									});
					/**
					 * 退货列表
					 */
					$("#orderInfo")
					.delegate(
							'#returnGoodsinfor',
							'click',
							function() {
								$("#returnDetail input").each(function() {
									$(this).prop("readonly", false);
								});
								var orderId = $('#orderId').val();
								alert("退货列表");
								$('#itemPagination2')
								.jqPaginator(
										{
											totalPages : addPageCount,
											visiblePages : 10,
											currentPage : 1,
											prev : '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
											page : '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
											next : '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
											onPageChange : function(num,type) {
												clearGoodsTable();
												getQueryForBG(bkGoodsArr.length);

											}
										});
								
							});
					
					/**
					 * 根据orderId查找订单详情
					 */
					function queryOrderDetail(orderId){
						var queryUrl = basePath+ "/manage/order/orderDetail/queryOrderDetail.do";
						$.ajax({
									url : queryUrl,
									type : "POST",
									dataType : 'json',
									data : {
										id : orderId
									},
									cache : false,
									success : function(data) {
										
										for (i = 0; i < data.resultList.length; i++) {
											var result = data.resultList[i];
											giftArr.push(result);
										}
									},
									error : function(html) {
										alert("出错了");
										return;
									}
								});
					}

					/**
					 * 全选当前页记录
					 */
					$("#orderList").delegate('#selectAll', 'click', function() {
						var isSelectAll = $(this).prop('checked');
						$("input[name='orderId']").each(function() {
							$(this).prop("checked", isSelectAll);
						});
					});
					function clearItemTable() {

						$("#itemsTable tr:not(:first)").remove();
					}
					function clearGoodsTable() {
						
						$("#goodsTable tr:not(:first)").remove();
					}

					/**
					 * 修改按钮事件
					 */

					$("#orderList")
							.delegate(
									'#editBtn',
									'click',
									function() {
										$("#returnGoodsinfor").hide();
										clearArrAll();//清空数组
										var orderId = $(this).attr("objId");
										$("#orderInfo input").removeAttr("readonly");
										$("#orderDetails input[name='summery']").attr({
											readonly : 'true'
										});
										$("#orderDetails input[name='orderCode']").attr({
											readonly : 'true'
										});
										$("#orderDetails input[name='mailFeed']").attr({
											readonly : 'true'
										});
										$("#orderInfo textarea").removeAttr("readonly");
										$("#orderInfo select").removeAttr("disabled");
										$("#orderInfo button").removeAttr("disabled");
										$("#orderInfo button[name='saveBtn']").show();
										$("#orderInfo button[name='confirmBtn']").hide();
										$("#orderInfo button[name='returnGoodsBtn']").hide();
										$("#orderInfo button[name='returnMoneyBtn']").hide();
										//获取订单详情
										queryOrderDetail(orderId);
										var editUrl = "show.do?orderId="+ orderId;
										$.ajax({

											url : editUrl,
											type : "POST",
											dataType : 'json',
											data : {
												id : orderId
											},
											cache : false,

											success : function(data) {
												loadOrder(data);
											},
											error : function(html) {
												alert("Load Data failly");
												refresh();
											}
										});

									});
					/**
					 * 批量发货
					 */

					$("#tools").delegate('#sendGoods', 'click', function() {
						delChk = $('input[name="orderId"]:checked');
						if (delChk.length > 0) {
							if (confirm("您确定发货吗?")) {

								var ids = "";
								var delUrl = "sendGoods.do";
								var idArr = new Array();

								for (var i = 0; i < delChk.length; i++) {
									idArr.push(delChk.get(i).value);

								}

								$.ajax({
									url : delUrl,
									type : "POST",
									data : {
										ids : idArr.toString()
									},
									cache : false,

									success : function(html) {
										alert("sendGoods successfully");
										refresh();
									},
									error : function(html) {
										alert("sendGoods failly");
										refresh();
									}
								});
							} else {
								return;
							}
						} else {
							alert("Please select the record to send");
							return;
						}
					});
					/**
					 * 批量退货
					 */
					$("#tools").delegate('#returnGoods', 'click', function() {
						delChk = $('input[name="orderId"]:checked');
						if (delChk.length > 0) {
							if (confirm("您确定要退货吗?")) {

								var ids = "";
								var delUrl = "returnGoods.do";
								var idArr = new Array();

								for (var i = 0; i < delChk.length; i++) {
									idArr.push(delChk.get(i).value);

								}

								$.ajax({
									url : delUrl,
									type : "POST",
									data : {
										ids : idArr.toString()
									},
									cache : false,

									success : function(html) {
										alert("returnGoods successfully");
										refresh();
									},
									error : function(html) {
										alert("returnGoods failly");
										refresh();
									}
								});
							} else {
								return;
							}
						} else {
							alert("Please select the record to returnGoods");
							return;
						}
					});
					/**
					 * 批量退款
					 */
					$("#tools").delegate('#returnMoney', 'click', function() {
						delChk = $('input[name="orderId"]:checked');
						if (delChk.length > 0) {
							if (confirm("您确定要退款吗?")) {

								var ids = "";
								var delUrl = "returnMoney.do";
								var idArr = new Array();

								for (var i = 0; i < delChk.length; i++) {
									idArr.push(delChk.get(i).value);

								}

								$.ajax({
									url : delUrl,
									type : "POST",
									data : {
										ids : idArr.toString()
									},
									cache : false,

									success : function(html) {
										alert("returnMoney successfully");
										refresh();
									},
									error : function(html) {
										alert("returnMoney failly");
										refresh();
									}
								});
							} else {
								return;
							}
						} else {
							alert("Please select the record to returnMoney");
							return;
						}
					});
					/*
					 * 删除记录
					 */
					$("#tools").delegate('#deleteBtn', 'click', function() {
						delChk = $('input[name="orderId"]:checked');

						if (delChk.length > 0) {
							if (confirm("Are you sure delete the record?")) {

								var ids = "";
								var delUrl = "delete.do";
								var idArr = new Array();

								for (var i = 0; i < delChk.length; i++) {
									idArr.push(delChk.get(i).value);

								}

								$.ajax({
									url : delUrl,
									type : "POST",
									data : {
										ids : idArr.toString()
									},
									cache : false,

									success : function(html) {
										alert("Delete successfully");
										refresh();
									},
									error : function(html) {
										alert("Delete failly");
										refresh();
									}
								});
							} else {
								return;
							}
						} else {
							alert("Please select the record to delete");
							return;
						}
					});

					$("#tools").delegate('#addOrder', 'click', function() {
						//生成订单编号
						var codeUrl = basePath+"/manage/order/getOrderCode.do";
						$.ajax({
							url : codeUrl,
							dataType : 'text',
							type:"POST",
							cache : false,
							
							success : function(data) {
								$("#orderDetails input[name='orderCode']").val(data);
							},
							error : function(html) {
								alert("生成订单编号失败");
								refresh();
							}
						});
						$("#orderInfo button[name='saveBtn']").show();
						$("#orderInfo button[name='confirmBtn']").hide();
						$("#orderInfo button[name='returnGoodsBtn']").hide();
						$("#orderInfo button[name='returnMoneyBtn']").hide();
						$("#orderInfo button").removeAttr("disabled");
						
						$("#orderDetails input").each(function() {
							$(this).prop("value", null);
							$(this).prop("readonly", false);

						});
						$("#orderDetails input[name='summery']").attr({
							readonly : 'true'
						});
						$("#orderDetails input[name='orderCode']").attr({
							readonly : 'true'
						});
						$("#orderDetails input[name='mailFeed']").attr({
							readonly : 'true'
						});
						$("#returnGoodsinfor").hide();
						$("#orderDetails textarea").each(function() {
							$(this).prop("value", null);

						});
						$("#orderDetails select").each(function() {
							$(this).prop("disabled", null);

						});
						clearItemTable();
						clearArrAll();
						$("#orderDetails").modal('show');
					});

					$("#searchInfor").delegate('[name="out"]', 'click',
							function() {
								$("#giftRules").find("option").remove();
								setSuggest(this);
							});

					$("#searchInfor").delegate('#clearItem', 'click',
							function() {
								if (confirm("真的要清空库单列表吗?") == true) {
									$("#itemsTable tr:not(:first)").remove();
									return;
								}

							});
					$("#backGoodsInfor").delegate('#clearGoodsItem', 'click',
							function() {
						if (confirm("真的要清空库单列表吗?") == true) {
							$("#goodsTable tr:not(:first)").remove();
							return;
						}
						
					});

					$("#searchInfor")
							.delegate(
									'#itemName',
									'change',
									function() {
										if (!isReading) {
											clearSuggest();
											var itemStr = $('#itemName').val();

											var ajaxUrl = encodeURI("queryGiftIds.do?condition="+ itemStr);
											$.ajax({
														url : ajaxUrl,
														dataType : "json",
														condition : itemStr,
														success : function(data) {
															if (data != null&& data.result.length > 0) {
																clearSuggest();
																for (i = 0; i < data.result.length; i++) {
																	var result = data.result[i];
																	
																	createSuggest(result);
																}
																
																displaySuggest();
															} else {
																hiddenSuggest();
															}
															isReading = false;

														},
														error : function(data) {
															alert("加载数据出错");
															return;

														}
													});

										}

									});
					$("#searchInfor")
							.delegate(
									'#itemName',
									'keyup',
									function() {
										
										if (!isReading) {
											clearSuggest();
											var itemStr = $('#itemName').val();
											
												var ajaxUrl = encodeURI("queryGiftIds.do?condition="
														+ itemStr);
												$.ajax({
															url : ajaxUrl,
															dataType : "json",
															condition : itemStr,
															success : function(
																	data) {
																if (data != null&& data.result.length > 0) {
																	for (i = 0; i < data.result.length; i++) {
																		var result = data.result[i];
																		createSuggest(result);
																	}
																	displaySuggest();
																} else {
																	hiddenSuggest();
																}
																isReading = false;

															},
															error : function(
																	data) {
																alert("加载数据出错");
																return;

															}
														});

											
										}

									});
					/*
					 * 
					 * 根据单价和数量计算出总价
					 */
					$("#itemsTable")
							.delegate(
									"input[itemName='total']",
									'change',
									function() {
										var total = $(this).val();
										var salePrice = $(this).parent().parent().children().children("input[itemName='salePrice']").val();
										var id = $(this).parent().parent().attr("id");
										var trId = $(this).attr("rowId");
										var giftDetailId = $("#giftDetailId_" + id).val();
										if(total>0){
											var queryUrl = basePath+ "/manage/giftDetail/getGiftDetailTotals.do?id="+giftDetailId;
											$.ajax({
												url : queryUrl,
												dataType : 'text',
												cache : false,
												success : function(data) {
													var giftNum = parseInt(data);
													if(giftNum >= total){
														$("#summery_" + id).val(salePrice * total);
															var ele = giftArr[trId];
															ele.total = total;
															ele.summery = salePrice * total;
															giftArr.splice(trId, 1, ele);
															
															//计算订单总额
															computerOrderSummery();
													}
													else{
														alert("库存量不足，请更改数量！");
														$("#summery_" + id).val("");
														$("#total_" + id).val("");
														return;
													}
												},
												error : function(html) {
													alert("出错了");
													return;
												}
											});
										}else{
											alert("数量不能为负数！！");
											$("#summery_" + id).val("");
											$("#total_" + id).val("");
											return;
										}
										
									});
					/**
					 * 备注
					 */
					$("#itemsTable")
					.delegate(
							"input[itemName='note']",
							'change',
							function() {
								alert("note change");
								var note = $(this).val();
								var id = $(this).parent().parent().attr("id");
								var trId = $(this).attr("rowId");
								var ele = giftArr[trId];
								ele.note = note;
								giftArr.splice(trId, 1, ele);
				});
					/**
					 * 退货备注
					 */
					$("#goodsTable")
					.delegate(
							"input[itemName='note']",
							'change',
							function() {
								var note = $(this).val();
								var id = $(this).parent().parent().attr("id");
								var trId = $(this).attr("rowId");
								var ele = bkGoodsArr[trId];
								ele.note = note;
								bkGoodsArr.splice(trId, 1, ele);
							});
									/**
									 * 计算订单总额
									 */
									function computerOrderSummery(){
										var order_summery =0;//记录订单总额
										for(i=0;i<giftArr.length;i++){
											var sum = giftArr[i].summery;
											order_summery = order_summery + parseInt(sum);
										}
										$(".order_summery").val(order_summery);
									}

					/*$("#itemsTable")
							.delegate(
									"input[itemName='total']",
									'blur',
									function() {
										var total = $(this).val();
										var salePrice = $(this).parent().parent().children().children("input[itemName='salePrice']").val();
										var id = $(this).parent().parent().attr("id");
										var trId = $(this).attr("rowId");
										$("#summery_" + id).val(salePrice * total);
										
											alert("trId=" + trId);
											var ele = giftArr[trId];
											ele.total = total;
											ele.summery = salePrice * total;
											giftArr.splice(trId, 1, ele);

									});*/
					/**
					 * 清空数组
					 */
					function clearArrAll(){
						if(giftArr.length>0){
							giftArr.splice(0,giftArr.length);
						}
					}
					/**
					 * 根据条形码构造出一个退货单
					 */
					$("#backGoodsInfor").delegate('#searchItem','click',function(){
						var orderId = $("#orderId").val();
						var snCode = $("#snCode").val();
						var loadSnCode = "getSnCodeByCode.do?";
						$.ajax({
							url : loadSnCode,
							dataType : "json",
							data : {
								snCode : snCode,
								orderId:orderId
							},
							success : function(data) {
								alert("successfully");
								if (data != null) {
									var goodsTable = $("#goodsTable");
									if (isSnCode(
											goodsTable,
											data) <= 0) {
										pushBackGoods(data);

									} else {
										alert("["
												+ data.id
												+ "]"
												+ data.snCode
												+ " 已存在于库单中..");
									}

									return;
								}
							},
							error : function(data) {
								alert("加载数据出错");
								return;

							}
						});
					});
					/**
					 * 添加礼品
					 */
					$("#searchInfor")
							.delegate(
									'#addItem',
									'click',
									function() {
										//clearArrAll();//清空数组
										var giftDetaiId = $("#giftRules").val();
										if (giftDetaiId != -1) {
											var loadProductUrl = basePath+ "/manage/giftDetail/loadGiftDetail.do?id="
													+ giftDetaiId;
											$.ajax({
														url : loadProductUrl,
														dataType : "json",
														success : function(data) {
															alert("successfully");
															if (data != null) {
																var itemTable = $("#itemsTable");
																if (isItemInOrder(
																		itemTable,
																		data) <= 0) {
																	pushGiftOrder(data);

																} else {
																	alert("["
																			+ data.giftCode
																			+ "]"
																			+ data.gdName
																			+ " 已存在于库单中..");
																}

																return;
															}

														},
														error : function(data) {
															alert("加载数据出错");
															return;

														}
													});
										} else {
											alert("请选择要添加的礼品规格！");
										}

									});
					/**
					 * 存储礼品
					 */
					function pushGiftOrder(data) {
						giftArr.push(data);
						len=giftArr.length;
						getQuery(len);// 分页
					}
					/**
					 * 存储退货单
					 */
					function pushBackGoods(data) {
						bkGoodsArr.push(data);
						len=bkGoodsArr.length;
						getQueryForBG(len);// 分页
					}
					/**
					 * 退货分页函数
					 */
					function getQueryForBG(len) {
						/**
						 * 添加的内分页
						 */
						if (len <= 5) {
							addPageCount = 1;
						} else {
							if (len % 5 == 0) {
								addPageCount = len / 5;
							} else {
								addPageCount = Math.floor((len / 5)) + 1;
							}
						}
						$('#itemPagination2')
								.jqPaginator(
										{
											totalPages : addPageCount,
											visiblePages : 10,
											currentPage : 1,
											prev : '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
											page : '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
											next : '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
											onPageChange : function(num, type) {
												clearGoodsTable();
												var goodsTable = $("#goodsTable");
												var start = num * 5 - 5;
												var end = num * 5;
												var idx = 0;
													for (i = start; i < bkGoodsArr.length; i++) {
														if(idx<5){
															addGoodsItemContent(goodsTable,bkGoodsArr[i],i);
															idx++;
														}
												}
											}
										});
						return true;
					}

					/**
					 * 分页函数
					 */
					function getQuery(len) {
						/**
						 * 添加的内分页
						 */
						if (len <= 5) {
							addPageCount = 1;
						} else {
							if (len % 5 == 0) {
								addPageCount = len / 5;
							} else {
								addPageCount = Math.floor((len / 5)) + 1;
							}
						}
						$('#itemPagination')
								.jqPaginator(
										{
											totalPages : addPageCount,
											visiblePages : 10,
											currentPage : 1,
											prev : '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
											page : '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
											next : '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
											onPageChange : function(num, type) {
												clearItemTable();
												var itemTable = $("#itemsTable");
												var start = num * 5 - 5;
												var end = num * 5;
												var orderId = $("#orderId").val();
												var idx = 0;
													for (i = start; i < giftArr.length; i++) {
														if(idx<5){
															if(orderId==null||orderId==""){
																addItemContent(itemTable,giftArr[i],i);
															}
															else{
																lookItemContent(itemTable,giftArr[i],i);
															}
															idx++;
														}
												}
											}
										});
						return true;
					}

					function setSuggest(src) {
						document.getElementById("itemName").value = src.innerHTML;
						document.getElementById("itemId").value = src.id;
						var itemId = $("#itemId").val();
						getOrderDetail(itemId);
						hiddenSuggest();
					}
					function resetReading() {
						if (!isReading) {
							isReading = true;
							readInfo();
						}
					}
					function readInfo() {
						var info = document.getElementById("itemName").value;
						if (currentInfo == info && info != "") {
							counter++;
						} else {
							currentInfo = info;
							counter = 1;
						}
						if (counter == 3) {
							getSuggest(info);
							isReading = false;
						} else {
							setTimeout("readInfo()", 200);
						}
					}
					
					/**
					 * 初始化邮递类型
					 */
					function getPostType(){
							var postUrl = basePath+"/web/orderInfor/post.do";
							$.ajax({

								url : postUrl,
								type : "POST",
								dataType : 'json',
								cache : false,

								success : function(data) {
									var results = data.postList;
									var commentStatus = $("#commentStatus");
									var rowContent = null;
									for(i=0;i<results.length;i++){
										var post = results[i];
										rowContent = rowContent+"<option  value ="+post.cost+" >"+post.name+"</option>";
									}
									commentStatus.append(rowContent);
								},
								error : function(html) {
									alert("Load Data failly");
									refresh();
								}
							});
						}
					/**
					 * 查看订单基本信息
					 */
					$("#orderList").delegate(
							'[name="watchGiftBtn"]',
							'click',
							function() {
								$("#orderInfo input").attr({
									readonly : 'true'
								});
								$("#orderInfo textarea").attr({
									readonly : 'true'
								});
								$("#orderInfo select").attr("disabled",
										"disabled");
								$("#orderInfo button[name='saveBtn']").attr("disabled",
								"disabled");
								$("#orderInfo button[name='saveBtn']").hide();
								$("#returnGoodsinfor").hide();
								
							});
					/**
					 * 单独发货
					 */
					$("#orderList").delegate(
							'[name="sendBtn"]',
							'click',
							function() {
								$("#orderInfo input").attr({readonly : 'true'});
								$("#orderInfo textarea").attr({readonly : 'true'});
								$("#orderInfo select").attr("disabled","disabled");
								$("#orderInfo button[name='confirmBtn']").show();
								$("#orderInfo button[name='saveBtn']").hide();
								$("#orderInfo button[name='returnMoneyBtn']").hide();
								$("#orderInfo button[name='returnGoodsBtn']").hide();
								$("#returnGoodsinfor").hide();
							});
					/**
					 * 单独退货
					 */
					$("#orderList").delegate(
							'[name="returnGoodsBtn"]',
							'click',
							function() {
								$("#orderInfo input").attr({readonly : 'true'});
								$("#orderInfo textarea").attr({readonly : 'true'});
								$("#orderInfo select").attr("disabled","disabled");
								$("#orderInfo button[name='confirmBtn']").hide();
								$("#orderInfo button[name='saveBtn']").hide();
								$("#orderInfo button[name='returnMoneyBtn']").hide();
								$("#orderInfo button[name='returnGoodsBtn']").show();
								$("#returnGoodsinfor").show();
							});
					/**
					 * 单独退款
					 */
					$("#orderList").delegate(
							'[name="returnMoneyBtn"]',
							'click',
							function() {
								$("#orderInfo input").attr({readonly : 'true'});
								$("#orderInfo textarea").attr({readonly : 'true'});
								$("#orderInfo select").attr("disabled","disabled");
								$("#orderInfo button[name='confirmBtn']").hide();
								$("#orderInfo button[name='saveBtn']").hide();
								$("#orderInfo button[name='returnGoodsBtn']").hide();
								$("#orderInfo button[name='returnMoneyBtn']").show();
							});
					/**
					 * 单独发货的封装方法
					 */
					function sendGiftMethod(orderId){
						var loadGiftInfor=basePath+ "/manage/order/sendGift.do?id="+orderId;
						$.ajax({
							url : loadGiftInfor,
							dataType : "text",
							success : function(data) {
								if(data=="success"){
									
									alert("发货成功");
								}
								else{
									alert("发货失败");
									
								}
								refresh();		
							},
							error : function(data) {
								alert("加载数据出错");
								return;

							}
						});
					}
					// 显示提示信息
					function displaySuggest() {
						document.getElementById("selectItem").style.display = "";
					}
					// 隐藏提示信息
					function hiddenSuggest() {
						document.getElementById("selectItem").style.display = "none";
					}
					// 清空提示信息
					function clearSuggest() {
						document.getElementById("selectItem").innerHTML = "";
					}
					/**
					 * 判断列表当中是否已经存在重复的礼品
					 */
					function isItemInOrder(itemTable, data) {
						var j = 0;
						for (var i = 0; i < giftArr.length; i++) {
							var g = giftArr[i];
							if (g == null || g == "" || g == "undefined") {
								continue;
							}
							var hashCode = data.gdName;
							if (hashCode == g.gdName) {
								j++;
							}

						}
						return j;
					}
					/**
					 * 判断列表当中是否已经存在重复的条形码
					 */
					function isSnCode(goodsTable, data) {
						var j = 0;
						for (var i = 0; i < bkGoodsArr.length; i++) {
							var g = bkGoodsArr[i];
							if (g == null || g == "" || g == "undefined") {
								continue;
							}
							var hashCode = data.snCode;
							if (hashCode == g.snCode) {
								j++;
							}
							
						}
						return j;
					}
					/**
					 * 获取礼品规格
					 */
					function getOrderDetail(giftId){
						var optStr = null;
						var detailsUrl=basePath+ "/manage/giftInfo/queryGiftDetails.do?giftId="+giftId;
						$.ajax({
							url : detailsUrl,
							dataType : "json",
							success : function(data) {
								
								alert("successfully");
								for(i=0;i<data.resultList.length;i++){
									var result = data.resultList[i];
									optStr =optStr+ "<option value='" + result.id + "'>"
									+ result.gdName + "</option>";
								}
								$("#giftRules").append(optStr);
							},
							error : function(data) {
								alert("加载数据出错");
								return;
							}
						});
						
						
					}

					function createSuggest(data) {
						var sDiv = "<div name='out' class='out' onmouseover=\"this.className='over'\""
								+ "onmouseout=\"this.className='out'\" id='"
								+ data.id + "'>" + data.giftName + "</div>";
						document.getElementById("selectItem").innerHTML += sDiv;
						
					}
					
					function addItemContent(itemTable, data, rowNum) {
						var rowContent = "<tr id="
								+ data.id
								+ "><td style='text-align: center;'><input type='hidden'  id='giftId_"
								+ data.id + "'  name='details[" + rowNum
								+ "].giftId' itemName='giftId' value='"
								+ data.giftId
								+ "' /><input type='text'  id='giftCode_"
								+ data.id + "'  name='details[" + rowNum
								+ "].giftCode' itemName='giftCode' value='"
								+ data.giftCode
								+ "' /><input type='hidden'  id='giftDetailId_"
								+ data.id + "'  name='details[" + rowNum
								+ "].giftDetailId' itemName='giftDetailId' value='"
								+ data.id + "' /><input type='hidden'  id='gdCode_"
								+ data.id + "'  name='details[" + rowNum
								+ "].gdCode' itemName='gdCode' value='"
								+ data.gdCode + "' /></td>";
						rowContent = rowContent
								+ "<td style='text-align: center;'><input id='giftName_"
								+ data.id + "' type='text' name='details["
								+ rowNum
								+ "].giftName' itemName='giftName' value='"
								+ data.giftName + "' /></td>";
						rowContent = rowContent
								+ "<td style='text-align: center;'><input id='gdPic_"
								+ data.id + "' type='hidden' name='details["+ rowNum
								+ "].gdPic' itemName='gdPic' value='"
								+ data.gdPic + "' /><input id='gdName_"
								+ data.id + "' type='text' name='details["+ rowNum
								+ "].gdName' itemName='gdName' value='"
								+ data.gdName + "' /></td>";
						rowContent = rowContent
								+ "<td style='text-align: center;'><input id='salePrice_"
								+ data.id + "' type='text' name='details["
								+ rowNum
								+ "].salePrice' itemName='salePrice' value='"
								+ data.salePrice + "'/></td>";
						if(data.total == null || data.total == 'undefined'){
							rowContent = rowContent
							+ "<td style='text-align: center;'><input  id='total_"
							+ data.id + "' type='text' name='details["
							+ rowNum + "].total' rowId='" + rowNum
							+ "' itemName='total' /></td>";
							rowContent = rowContent
							+ "<td style='text-align: center;'><input id='summery_"
							+ data.id + "' type='text' name='details["
							+ rowNum + "].summery' rowId='" + rowNum
							+ "' itemName='summery' /></td>";
							
						}
						else{
							
							rowContent = rowContent
							+ "<td style='text-align: center;'><input  id='total_"
							+ data.id + "' type='text' name='details["
							+ rowNum + "].total' rowId='" + rowNum
							+ "' itemName='total' value='"+data.total+"'/></td>";
							rowContent = rowContent
							+ "<td style='text-align: center;'><input id='summery_"
							+ data.id + "' type='text' name='details["
							+ rowNum + "].summery' rowId='" + rowNum
							+ "' itemName='summery' value='"+data.summery+"'/></td>";
							
						}
						if(data.note==null||data.note=='undefined'){
							rowContent = rowContent
							+ "<td style='text-align: center;'><input id='note_"
							+ data.id + "' type='text' name='details["
							+ rowNum + "].note' rowId='" + rowNum
							+ "' itemName='note' /></td>";
						}
						else{
							rowContent = rowContent
							+ "<td style='text-align: center;'><input id='note_"
							+ data.id + "' type='text' name='details["
							+ rowNum + "].note' rowId='" + rowNum
							+ "' itemName='note' value='"+data.note+"'/></td>";
						}
						rowContent = rowContent
								+ "<td style='text-align: center;'><button name='delItem' rowId='"
								+ rowNum + "' type='button'>删除</button></td>";
						rowContent = rowContent + "</tr>";
						itemTable.append(rowContent);
					}
					function lookItemContent(itemTable, data,rowNum) {
						if(data.giftDetailId==null||data.giftDetailId == 'undefined'){
							var rowContent = "<tr id="
								+ data.id
								+ "><td style='text-align: center;'><input type='hidden'  id='giftId_"
								+ data.id + "'  name='details[" + rowNum
								+ "].giftId' itemName='giftId' value='"
								+ data.giftId
								+ "' /><input type='text'  id='giftCode_"
								+ data.id + "'  name='details[" + rowNum
								+ "].giftCode' itemName='giftCode' value='"
								+ data.giftCode
								+ "' /><input type='hidden'  id='giftDetailId_"
								+ data.id + "'  name='details[" + rowNum
								+ "].giftDetailId' itemName='giftDetailId' value='"
								+ data.id + "' /><input type='hidden'  id='gdCode_"
								+ data.id + "'  name='details[" + rowNum
								+ "].gdCode' itemName='gdCode' value='"
								+ data.gdCode + "' /></td>";
							
						}
						else{
							var rowContent = "<tr id="
								+ data.id
								+ "><td style='text-align: center;'><input type='hidden'  id='giftId_"
								+ data.id + "'  name='details[" + rowNum
								+ "].giftId' itemName='giftId' value='"
								+ data.giftId
								+ "' /><input type='text'  id='giftCode_"
								+ data.id + "'  name='details[" + rowNum
								+ "].giftCode' itemName='giftCode' value='"
								+ data.giftCode
								+ "' /><input type='hidden'  id='id_" + data.id
								+ "'  name='details[" + rowNum
								+ "].id' itemName='id' value='" + data.id
								+ "' /><input type='hidden'  id='giftDetailId_"
								+ data.id + "'  name='details[" + rowNum
								+ "].giftDetailId' itemName='giftDetailId' value='"
								+ data.giftDetailId + "' /><input type='hidden'  id='gdCode_"
								+ data.id + "'  name='details[" + rowNum
								+ "].gdCode' itemName='gdCode' value='"
								+ data.gdCode + "' /></td>";
						}
						rowContent = rowContent
								+ "<td style='text-align: center;'><input id='giftName_"
								+ data.id + "' type='text' name='details["
								+ rowNum
								+ "].giftName' itemName='giftName' value='"
								+ data.giftName + "' /></td>";
						rowContent = rowContent
								+ "<td style='text-align: center;'><input id='gdPic_"
								+ data.id + "' type='hidden' name='details["+ rowNum
								+ "].gdPic' itemName='gdPic' value='"
								+ data.gdPic + "' /><input id='gdName_"
								+ data.id + "' type='text' name='details["+ rowNum
								+ "].gdName' itemName='gdName' value='"
								+ data.gdName + "' /></td>";
						rowContent = rowContent
								+ "<td style='text-align: center;'><input id='salePrice_"
								+ data.id + "' type='text' name='details["
								+ rowNum
								+ "].salePrice' itemName='salePrice' value='"
								+ data.salePrice + "'/></td>";
						if(data.total == null || data.total == 'undefined'){
							rowContent = rowContent
								+ "<td style='text-align: center;'><input  id='total_"
								+ data.id + "' type='text' name='details["
								+ rowNum + "].total' rowId='" + rowNum
								+ "' itemName='total' /></td>";
							rowContent = rowContent
								+ "<td style='text-align: center;'><input id='summery_"
								+ data.id + "' type='text' name='details["
								+ rowNum + "].summery' rowId='" + rowNum
								+ "' itemName='summery' /></td>";
						}
						else{
							
							rowContent = rowContent
								+ "<td style='text-align: center;'><input  id='total_"
								+ data.id + "' type='text' name='details["
								+ rowNum + "].total' rowId='" + rowNum
								+ "' itemName='total' value='"+data.total+"'/></td>";
							rowContent = rowContent
								+ "<td style='text-align: center;'><input id='summery_"
								+ data.id + "' type='text' name='details["
								+ rowNum + "].summery' rowId='" + rowNum
								+ "' itemName='summery' value='"+data.summery+"'/></td>";
						}
						if(data.note==null||data.note=='undefined'){
							rowContent = rowContent
							+ "<td style='text-align: center;'><input id='note_"
							+ data.id + "' type='text' name='details["
							+ rowNum + "].note' rowId='" + rowNum
							+ "' itemName='note' /></td>";
						}
						else{
							rowContent = rowContent
							+ "<td style='text-align: center;'><input id='note_"
							+ data.id + "' type='text' name='details["
							+ rowNum + "].note' rowId='" + rowNum
							+ "' itemName='note' value='"+data.note+"'/></td>";
						}
						rowContent = rowContent
								+ "<td style='text-align: center;'><button name='delItem' rowId='"
								+ rowNum + "' type='button'>删除</button></td>";
						rowContent = rowContent + "</tr>";
						itemTable.append(rowContent);
						rowNum++;
					}
					function addGoodsItemContent(goodsTable, data, rowNum) {
						var rowContent = "<tr id="
								+ data.id
								+ "><td style='text-align: center;'><input type='hidden'  id='orderId_"
								+ data.id + "'  name='goodsList[" + rowNum
								+ "].orderId' itemName='orderId' value='"
								+ data.orderId
								+ "' /><input type='hidden'  id='snCodeId_"
								+ data.id + "'  name='goodsList[" + rowNum
								+ "].snCodeId' itemName='snCodeId' value='"
								+ data.snCodeId
								+ "' /><input type='hidden'  id='orderDetailId_"
								+ data.id + "'  name='goodsList[" + rowNum
								+ "].orderDetailId' itemName='orderDetailId' value='"
								+ data.orderDetailId
								+ "' /><input type='hidden'  id='giftDetailId_"
								+ data.id + "'  name='goodsList[" + rowNum
								+ "].giftDetailId' itemName='giftDetailId' value='"
								+ data.giftDetailId
								+ "' /><input type='text'  id='giftCode_"
								+ data.id + "'  name='goodsList[" + rowNum
								+ "].giftCode' itemName='giftCode' value='"
								+ data.giftCode
								+ "' /></td>";
						rowContent = rowContent
								+ "<td style='text-align: center;'><input id='giftName_"
								+ data.id + "' type='text' name='goodsList["
								+ rowNum
								+ "].giftName' itemName='giftName' value='"
								+ data.giftName + "' /></td>";
						rowContent = rowContent
								+ "<td style='text-align: center;'><input id='giftDetailName_"
								+ data.id + "' type='text' name='goodsList["+ rowNum
								+ "].giftDetailName' itemName='giftDetailName' value='"
								+ data.giftDetailName + "' /></td>";
						rowContent = rowContent
								+ "<td style='text-align: center;'><input id='snCode_"
								+ data.id + "' type='text' name='goodsList["+ rowNum
								+ "].snCode' itemName='snCode' value='"
								+ data.snCode + "' /></td>";
						
						rowContent = rowContent
								+ "<td style='text-align: center;'><input id='salePrice_"
								+ data.id + "' type='text' name='goodsList["
								+ rowNum
								+ "].salePrice' itemName='salePrice' value='"
								+ data.salePrice + "'/></td>";
						if(data.note==null||data.note=='undefined'){
							
							rowContent = rowContent
							+ "<td style='text-align: center;'><input id='note_"
							+ data.id + "' type='text' name='goodsList["
							+ rowNum + "].note' rowId='" + rowNum
							+ "' itemName='note' /></td>";
						}
						else{
							rowContent = rowContent
							+ "<td style='text-align: center;'><input id='note_"
							+ data.id + "' type='text' name='goodsList["
							+ rowNum + "].note' rowId='" + rowNum
							+ "' itemName='note' value='"+data.note+"'/></td>";
						}
						
						rowContent = rowContent
								+ "<td style='text-align: center;'><button name='delGoodsItem' rowId='"
								+ rowNum + "' type='button'>删除</button></td>";
						rowContent = rowContent + "</tr>";
						goodsTable.append(rowContent);
					}
				});
				
				

function loadOrder(order) {
	$("#orderId").val(order.id);
	$("#orderCode").val(order.orderCode);
	$("#summery").val(order.summery);
	$("#createTime").val(order.createTime);
	$("#sendTime").val(order.sendTime);
	$("#sendAddr").val(order.sendAddr);
	$("#sender").val(order.sender);
	$("#postCode").val(order.postCode);
	$("#receAddr").val(order.receAddr);
	$("#receTime").val(order.receTime);
	$("#memberId").val(order.memberId);
	$("#memberName").val(order.memberName);
	$("#receiver").val(order.receiver);
	$("#ispost").val(order.ispost);
	$("#mailFeed").val(order.mailFeed);
	$("#payType").val(order.payType);
	$("#status").val(order.status);
	$("#note").val(order.note);
	$("#orderDetails").modal('show');
}
/**
 * 计算邮费
 * @param cost
 */
function changePostType(cost){
	
	$("#mailFeed").val(cost);//邮费
}



function vaildate(form) {
	return true;
}

function refresh() {
	window.location.reload();
}
